package site.yunnong.atvris.service.impl;

import com.github.pagehelper.PageHelper;
import org.springframework.stereotype.Service;
import site.yunnong.atvris.dao.domain.Tags;
import site.yunnong.atvris.dao.domain.TagsExample;
import site.yunnong.atvris.dao.mapper.TagsMapper;
import site.yunnong.atvris.service.TagsService;

import javax.annotation.Resource;
import java.util.List;

/**
 * 标签表
 *
 * @author zhangjinghao
 * @email jhzhang9102@163.com
 * @date 2021-07-09 23:45:38
 */
@Service
public class TagsServiceImpl implements TagsService {

    @Resource
    private TagsMapper tagsMapper;

    @Override
    public List<Tags> queryAll() {
        return tagsMapper.selectByExample(new TagsExample());
    }

    @Override
    public List<Tags> queryByName(String name) {
        TagsExample example = new TagsExample();
        example.createCriteria().andNameLike(name + "%");
        return tagsMapper.selectByExample(example);
    }

    @Override
    public List<Tags> querByPage(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        return tagsMapper.selectByExample(new TagsExample());
    }

    @Override
    public int insert(Tags tag) {
        return tagsMapper.insert(tag);
    }
}

